package com.dl.base.api.websocket.bean

import com.dl.base.api.websocket.cache.ICacheTarget
import okhttp3.WebSocket
import okio.ByteString

class WebSocketInfo : ICacheTarget<WebSocketInfo> {
    var webSocket: WebSocket? = null
    var stringMsg: String? = null
    var byteStringMsg: ByteString? = null

    /**
     * 是否连接成功
     */
    var isConnect: Boolean = false

    /**
     * 是否重连成功
     */
    var isReconnect = false

    /**
     * 是否准备重连
     */
    var isPrepareReconnect = false

    /**
     * 是否连接超时
     */
    var isConnectTimeOut = false

    override fun reset(): WebSocketInfo {
        webSocket = null
        stringMsg = null
        byteStringMsg = null
        isConnect = false
        isPrepareReconnect = false
        isReconnect = false
        isConnectTimeOut = false
        return this
    }

    override fun toString(): String {
        return "WebSocketInfo(webSocket=$webSocket, stringMsg=$stringMsg, byteStringMsg=$byteStringMsg, isConnect=$isConnect, isReconnect=$isReconnect, isPrepareReconnect=$isPrepareReconnect, isConnectTimeOut=$isConnectTimeOut)"
    }
}